typedef WillSet<T> = void Function({T newValue});
typedef DidSet<T> = void Function({T oldValue});

class Observing<T> {
  T _value;

  WillSet<T>? willSet;

  DidSet<T>? didSet;

  T get value => _value;

  set value(T newValue) {
    willSet?.call(newValue: newValue);

    final oldValue = _value;
    _value = newValue;

    didSet?.call(oldValue: oldValue);
  }

  Observing(T value, {this.willSet, this.didSet}) : _value = value;
}
